//
//  NSDictionary+LBAddition.m
//  LBFoundation
//
//  Created by WuShiHai on 19/5/24.
//  Copyright (c) 2019 Lebbay. All rights reserved.
//

#import "NSDictionary+LBAddition.h"

@implementation NSDictionary (LBAddition)

- (NSString *)URLParamterString {
    NSString *URLParamterString = @"";
    NSMutableArray *parameters = [@[] mutableCopy];
    [self enumerateKeysAndObjectsUsingBlock:^(id  _Nonnull key, id  _Nonnull obj, BOOL * _Nonnull stop) {
        if ([key isKindOfClass:[NSString class]] && ([obj isKindOfClass:[NSString class]] || [obj isKindOfClass:[NSNumber class]])) {
            [parameters addObject:[NSString stringWithFormat:@"%@=%@", [key stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding], [obj stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
        }
    }];
    URLParamterString = [parameters componentsJoinedByString:@"&"];
    
    return URLParamterString;
}

@end
